package com.itheima.d02_thread_create;

import com.itheima.d01_thread_create.MyThread;

/**
 * 目标：
 *  掌握创建线程方式二：实现Runnable
 */
public class Test2Runnable {

    public static void main(String[] args) {
        //需求：同时播放音乐，同时下载学习资料，同时浏览器网页

        //3.创建线程任务对象
        MyRunnable runnable = new MyRunnable();

        //4.把任务对象交给Thread处理
        Thread thread = new Thread( runnable );
        thread.start();


        //5.创建一个新的线程，浏览器网页
        Thread thread2 = new Thread( () -> {
                for (int i = 0; i < 10; i++) {
                    System.out.println("子线程2：浏览器网页..." + i);
                }
        });

        thread2.start();


        for (int i = 0; i < 10; i++) {
            System.out.println("main主线程：播放音乐... ..." + i);
        }
    }
}
